﻿CREATE PROCEDURE [dbo].[spCreatePaymentTransaction]
	@OrderID int
AS
declare @JournalID int

insert into tblJournal ( JournalEntryCode, Amount, CreateDate, JournalStatusCode, BankCheckNumber, OrderID )
select 'B', OrderTotal, GETDATE(), 'E', BankCheckNumber, @OrderID
from tblOrderHeader 
where OrderID = @OrderID

set @JournalID = SCOPE_IDENTITY()

-- Create the TransactionSubmit record
insert into tblTransactionSubmit ( JournalID, AccountID, CreateDate, SubmissionCount )
select @JournalID, AccountID, GETDATE(), 1
from tblOrderHeader
where OrderID = @OrderID

RETURN 0